(function () {
 
    var Twitter_ID = 'G_I_N', BLOG_TITLE = '|じんsぶろぐ';
 
if (!(/Trident|Firefox/i.test(navigator.userAgent))) {
    navigator.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30';
}
 
function generate_button_text(url, // @param String:
                              title) { // @param String:
                                       // @return String:
    var hatena_btn, twitter_btn, tumblr_btn, ameba_btn, mixi_btn, gplus_btn, facebook_btn, twitter_follow_btn;
 
    hatena_btn = '<a href="' + url + '" class="hatena-bookmark-button" data-hatena-bookmark-title="' +
                 title + '" data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加">' +
                 '<img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>';
    twitter_btn = '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="' + Twitter_ID + '" data-text="' +
                   title + BLOG_TITLE + '" data-url="' + url + '">Tweet</a>';
    if (/Firefox/i.test(navigator.userAgent)) {
    tumblr_btn = '<a href="http://www.tumblr.com/share?v=3&u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title + BLOG_TITLE) + '" ' +
                 'title="Share on Tumblr" ' +
                 'style="display:inline-block; overflow:hidden; width:61px; height:20px; ' +
                 'background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;" ' +
                 'data-text="' + title + BLOG_TITLE + '" data-url="' + url + '"></a>';
    } else {
    tumblr_btn = '<a href="http://www.tumblr.com/share" title="Share on Tumblr" ' +
                 'style="display:inline-block; overflow:hidden; width:61px; height:20px; ' +
                 'background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;" ' +
                 'data-text="' + title + BLOG_TITLE + '" data-url="' + url + '"></a>';
    }
    ameba_btn = '<a rel="nofollow" target="_blank" href="http://stat100.ameba.jp/blog/proxy.html?longurl=' + url + '&title=' + title + '&type=now">' +
                '<img src="http://stat100.ameba.jp/common_style/img/common/btn/btn_share_now.gif" alt="なうで紹介"></a>';
    mixi_btn = '<a rel="nofollow" target="_blank" href="http://stat100.ameba.jp/blog/proxy.html?longurl=' + url + '&type=mixi">' +
               '<img src="http://stat100.ameba.jp/common_style/img/common/btn/btn_share_mixi.png" alt="mixiチェック"></a>';
    gplus_btn = '<div class="g-plusone" size="medium" data-size="medium" data-count="true" href=' + url + '></div>';
    facebook_btn = '<iframe src="http://www.facebook.com/plugins/like.php?href='+ encodeURIComponent(url) +
                   '&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light&height=21" scrolling="no" ' +
                   'frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe> ';
    twitter_follow_btn = '<a href="http://twitter.com/' + Twitter_ID + '" class="twitter-follow-button" data-show-count="false" data-width="140px" data-lang="ja">Follow @' + Twitter_ID + '</a>';
 
    return [hatena_btn, twitter_btn, tumblr_btn, ameba_btn, mixi_btn, gplus_btn, facebook_btn, twitter_follow_btn].join('&nbsp');
}
 
$(document).ready(function(){
    var infos = [],
        target_node;
 
    $.getScript('http://b.st-hatena.com/js/bookmark_button.js');
    $.getScript('http://platform.twitter.com/widgets.js');
    $.getScript('http://platform.tumblr.com/v1/share.js');
    $.getScript("http://apis.google.com/js/plusone.js",function(){{lang: 'ja'}});
    if (location.href.match(/^.+\/entrylist[\-0-9]*\.html$/g )) {
        $('.newentrytitle a')
            .each(function (idx, // @param Number:
                            node) { // @param Node: each Element;
                infos[idx] = [node.toString(), node.text()];
            });
        target_node = $('.updatetime');
    } else {
        $('.foot a:contains("記事URL")')
            .each(function (idx, // @param Number:
                            node) { // @param Node: each Element;
                infos[idx] = [node.toString(), $("div.entry h3.title").eq(idx).text()];
            });
        target_node = $('div.foot');
    }
    $.each(infos, function (idx, // Number:
                     elm) { // Array:
        target_node.
            eq(idx).
            before(generate_button_text(elm[0], elm[1]));
    });
});
 
}());